﻿using Domain.Entitys;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFCore
{
	public class EIContext:DbContext
	{
		/// <summary>
		/// 配置链接字符串
		/// </summary>
		/// <param name="optionsBuilder"></param>
		protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
		{
			//链接字符串
			string connStr = "Data Source=.;Initial Catalog=HR_DB;Integrated Security=True;Connect Timeout=30;Encrypt=False;";
			//string connStr = "Data Source=KING;Initial Catalog=HR;Integrated Security=True;Connect Timeout=30;Encrypt=false;pooling=true;";
			optionsBuilder.UseSqlServer(connStr);
		}

		/// <summary>
		/// 读取配置类
		/// </summary>
		/// <param name="modelBuilder"></param>
		protected override void OnModelCreating(ModelBuilder modelBuilder)
		{
			//程序集
			modelBuilder.Entity<EI>(entity =>
			{
				entity.ToTable("EI");
			});
		}
		public DbSet<EI> EI { get; set; }
	}
}
